<!-- 原版 -->
<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
  <title>进度--接收的任务</title>

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="images/bee.png">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">
  <!-- <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png"> -->

  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  <!-- <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png"> -->

  <!-- Tile icon for Win8 (144x144 + tile color) -->
  <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileColor" content="#0e90d2">

  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  <link rel="stylesheet" href="assets/css/app.css">
  <script src="../../routes/vue.js"></script>
  <link rel="stylesheet" href="https://unpkg.com/nprogress@0.2.0/nprogress.css">
  <!-- <script src='nprogress.js'></script>
<link rel='stylesheet' href='nprogress.css'/> -->
</head>
<body style="background: url(images/bg1.png) no-repeat;background-size: cover; background-attachment:fixed;">
<!--在这里编写你的代码-->
  <!-- 页头 -->
  <header data-am-widget="header"
  class="am-header am-header-default" style="background-color: #F6B541;">
  <div class="am-header-left am-header-nav">
    <!-- <a href="#left-link">
        <span class="am-header-nav-title">
          首页
        </span>
    
          <i class="am-header-icon am-icon-home"></i>
    </a> -->
    <ul>
      <a href="yfpage.html">
        <li style="display: flex;flex-direction: row;width: 200px;">
            <img src="images/shouye.png" alt="管理员联系方式" style="width: 150px; height: 22px;margin-top: 10px; margin-left: -10%;">
            <!-- <p style="color: #000; margin-top: 0;font-size: 16px;">小蜜蜂图片收集网</p> -->
        </li>
      </a>
    </ul>
    </div>
    
  
    <div class="am-header-right am-header-nav">
      <a href="jobfachu.html">
        <div style="display: flex;flex-direction: column;margin-left: -40px;">
          <img src="images/rw.png" alt="管理员联系方式" style="width: 30px; height: 25px;">
          <span style="color: black; font-weight: 700; font-size: 12px;margin-left: -48px; margin-top: -14px;" onclick="rw()">任务</span>
        </div>
      </a>
      <a href="personal.html">
        <div style="display: flex;flex-direction: column;margin-left: -10px;">
          <img src="images/xr.png" alt="管理员联系方式" style="width: 25px; height: 20px;">
          <span style="color: black; font-weight: 700; font-size: 12px;margin-left: -18px; margin-top: -14px;" onclick="per()">我的</span>
        </div>
      </a>
    </div>

  </header>

  <div class="am-container" style="background-color: rgba(241, 246, 249, 0.65); margin-top: 60px; 
   box-shadow: 5px 5px 5px rgba(0,0,0,0.1); 
  border-radius: 5px; ">
     <div class="am-g am-g-fixed" style="margin-top: 2vh;" id="cycle" v-for="(item ,i) in arrs">
            <div class="am-u-sm-2 am-u-sm-offset-1" style="height: 30px; font-size:large; font-family: SimHei; font-weight: 700;">
                <label style="background-color: #fff;">任务编号：</label>
                <label style="background-color: #fff;">{{item.tasknum}}</label>
            </div>
            <div class="am-u-sm-6 am-u-end" style="height: 30px; font-size:large;">
                <label style="background-color: #fff;">收集日期：</label>
              <label style="background-color: #fff; width: 8vw;text-align: center;">{{item.begintime}}</label>
                    <span style="width: 8vw;">--</span>
                    <label style="background-color: #fff; width: 8vw;text-align: center;"> {{item.endtime}}</label>
            </div>
	</div>
          <div class="am-g am-g-fixed" style="margin-top: 5vh;">
            <div class="am-u-sm-5" style="height: 30px; font-size:large; font-family: SimHei; font-weight: 700;">
                图片收集进度<img src="images/xia.png" style="width: 25px;height:25px;">
                <!-- <button type="button" class="am-btn am-btn-primary am-round" style="background-color: #75C3B6;
                            width:6vw;height:3vh;font-size: xx-small;">全部采用</button> -->
            </div>
            <div class="am-u-sm-3" id="buttonstatus">
              <div class="am-form-group am-form-file" >
                <button type="button" id="font" class="am-btn am-btn-default am-btn-sm" style="background-color: #F6B541;border-radius: 50px;
                height: 40px;width: 150px;"></button>
                  <!-- <i class="am-icon-cloud-upload"></i> 上传图片</button> -->
                  <input type="file" id="choosefile" multiple>
              </div>
            </div>
          </div>
          <script>

          </script>

          <ul data-am-widget="gallery" class="am-gallery am-avg-sm-3
          am-avg-md-3 am-avg-lg-4 am-gallery-default" data-am-gallery="{ pureview: true }" id="picturelist">
          <li style="margin-bottom:20px;" v-for="(item ,i) in arrx">
            <div class="am-gallery-item" style="height: 126.4px;line-height: 126.4px; width: 230.4px; text-align: center;">
                <a>
                  <img v-bind:src="item.picurl" style="max-width:100%;max-height:100%;width:auto;height:auto; vertical-align: bottom;" >
                </a>
            </div>
          </li>
          </ul>
</div>
  

<!-- 页脚 -->
<footer data-am-widget="footer"
class="am-footer am-footer-default"
 data-am-footer="{  }" style="background-color: rgba(255,255,255,0) ;">
<div class="am-footer-switch">
<span class="am-footer-ysp" data-rel="mobile"
data-am-modal="{target: '#am-switch-mode'}">
云适配版
</span>
<span class="am-footer-divider"> | </span>
<a id="godesktop" data-rel="desktop" class="am-footer-desktop" href="javascript:">
电脑版
</a>
</div>
<div class="am-footer-miscs ">

<p>由 <a href="http://www.yunshipei.com/" title="诺亚方舟"
                                      target="_blank">诺亚方舟</a>
  提供技术支持</p>
<p>CopyRight©2014  AllMobilize Inc.</p>
<p>京ICP备13033158</p>
<br>
<p>NaN团队--小蜜蜂图片收集网</p>
</div>
</footer>

<div id="am-footer-modal"
class="am-modal am-modal-no-btn am-switch-mode-m am-switch-mode-m-default">
<div class="am-modal-dialog">
<div class="am-modal-hd am-modal-footer-hd">
<a href="javascript:void(0)" data-dismiss="modal" class="am-close am-close-spin " data-am-modal-close>&times;</a>
</div>
<div class="am-modal-bd">
您正在浏览的是

<span class="am-switch-mode-owner">
  云适配
</span>

<span class="am-switch-mode-slogan">
    为您当前手机订制的移动网站。
</span>
</div>
</div>
</div>

 

<!--[if (gte IE 9)|!(IE)]><!-->
<!-- <script src="assets/js/jquery.min.js"></script> -->
<!--<![endif]-->
<!--[if lte IE 8 ]-->
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<script src="https://unpkg.com/nprogress@0.2.0/nprogress.js"></script>
<!--[endif]-->
<script src="assets/js/amazeui.min.js"></script>

<script>

  function oneValues()
  {
    var result;
    var url=decodeURI(window.location.search); //获取url中"?"符后的字串  
    if(url.indexOf("?") != -1) {
        result = url.substr(url.indexOf("=")+1);
    }
    return result;
  }
  var $file = $("#choosefile");
    console.log($file)
    fileList=[],
    curFile=[],
    sendList=[],
    successlist = []
    failurelist = []
    list1=['']
    list3=[]
  $file.on('change',async function(){       
    curFile = this.files;
    //将FileList对象变成数组
    fileList = fileList.concat(Array.from(curFile));
    await ds(fileList,sendList,list1,successlist,failurelist,list3)
    window.location.href='./failure.html'
})

  function ds(fileList,sendList,list1,successlist,failurelist,list3){
    return new Promise(async (resolve,reject)=>{
      // var progress = $.AMUI.progress;
      // progress.start();
      NProgress.start()
      console.log(list1)
      for(var i=0,len = fileList.length;i < len;i++){
        //实例化fileReader,
        let  fd = new FileReader();
        //获取当前选择文件的类型
        let fileType = fileList[i].type;
                //监听它的onload事件，load完读取的结果就在它的result属性里了
        fd.onload = function(){
          console.log(this.result)
          list1.push(this.result)
      sessionStorage.setItem("list1", list1);
          console.log(list1)
          console.log(list1[0])
        }
        //调它的readAsDataURL并把原生File对象传给它，
        fd.readAsDataURL(fileList[i]);//base64

      }
      console.log(list1)
      if(fileList.length>0){
        for(var i=0,len = fileList.length;i < len;i++){
          let formData = new FormData();
          console.log("图片上传")
          formData.append('file',fileList[i]);
          await $.ajax({
              url:'http://localhost/uppicture?username='+window.sessionStorage.getItem("username")+'&tasknum='+vms.arrs[0]["tasknum"]+'&serial='+i,
              type:'post',
              data:formData,
              processData:false,
              contentType:false,
              success:function(data,statusText,headers){
                  if(data.success){
                  }
                  else{
                    console.log('jjjlll')
                    var filed = data;
                    console.log(filed)
                    sendList.push(filed);
                  }
              }
          })          
        }
        console.log('下面是sendlist')
        console.log(sendList)
        console.log(sendList.length)
        for(var i=0;i<sendList.length;i++){
      if(sendList[i]['msg']=='成功'){
        successlist.push(sendList[i])
      }
      else if(sendList[i]['msg']=='失败'){
        failurelist.push(sendList[i])
      }
    }
    console.log(failurelist)
    console.log(successlist)
    for(var i=0;i<failurelist.length;i++){
      list3.push(failurelist[i]['serial'])
    }
    console.log(list3)
    sessionStorage.setItem("failurelist", failurelist);
    sessionStorage.setItem("successlist", successlist);
    sessionStorage.setItem('list3',list3);
    console.log(sessionStorage.getItem('list3'))
    // progress.done();
    NProgress.done()
    }
    else{
        alert("请选择文件！")
    }
    resolve('hhh')
    })
  }
  

  var http = new XMLHttpRequest()
  http.open('POST','http://localhost/search')
  http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  http.send('key=' + oneValues())
  http.onreadystatechange = function(){
    if(http.readyState == 4 && http.status == 200)
    {
      console.log('search请求部分：输出responseText')
      console.log(http.responseText)
      // console.log(eval(http.responseText))
      var theNew = JSON.parse(http.responseText).a
      console.log(theNew)
      if(http.responseText.indexOf(true)+1)
      {
        console.log('输出theNew[0]')
        console.log(theNew[0])
        vms.arrs.push(theNew[0])
        console.log(vms.arrs.length)
        var bstatus=document.getElementById('choosefile');
        $bfont=$('#font');
        var normalizeDate = vms.arrs[0]['endtime'].split("-");
        console.log('sjh')
        console.log(normalizeDate)
        var day=new Date().getDate();
        var Month = new Date().getMonth() + 1;
        var year = new Date().getFullYear();
        console.log(day)
        console.log(Month)
        console.log(year)

        var status=sessionStorage.getItem('status')
        console.log(status)

        if(status=='已结束'){
          console.log('结束了哈')
          bstatus.disabled=true;
          $(function(){$bfont.empty()
                        $bfont.append('任务已结束')})
          }
          else{
            console.log('haole')
            if (normalizeDate[0] < year) {
          console.log('年份到期了')
          bstatus.disabled=true;
          $(function(){$bfont.empty()
          $bfont.append('任务已结束')})
        } else if(normalizeDate[0] == year){
          console.log('年份未到期')
            if (normalizeDate[1] < Month) {
                console.log('月分到期了')
                bstatus.disabled=true;
                $(function(){$bfont.empty()
          $bfont.append('任务已结束')})
            }else if(normalizeDate[1] == Month){
              console.log('月分未到期')
                if (normalizeDate[2] < this.day) {
                  console.log('日期到期了')
                  bstatus.disabled=true;
                  $(function(){$bfont.empty()
          $bfont.append('任务已结束')})
                }else {
                  console.log('日期未到期')
                  bstatus.disabled=false;
                  $(function(){$bfont.empty()
          $bfont.append('<i class="am-icon-cloud-upload"></i> 上传图片')})
                };
              }
              else{
                bstatus.disabled=false;
                $(function(){$bfont.empty()
          $bfont.append('<i class="am-icon-cloud-upload"></i> 上传图片')})
              }
            }
            else{
              bstatus.disabled=false;
              $(function(){$bfont.empty()
          $bfont.append('<i class="am-icon-cloud-upload"></i> 上传图片')})
            }
          }
      }
    }
  }
  var vms = new Vue({
    el: '#cycle',
    data: {
      arrs:[]
    },
    methods: {
      details: function(a) {
        console.log(a)
        vms.arrs.push(a)
        console.log(vms.arrs.length)
      }
    }
  })
</script>


<!-- 查看 -->
<script>
  $none=$('.none');
  var vmx = new Vue({
    el: '#picturelist',
    data: {
      arrx:[]
    },
    methods: {
      details: function(b) {
        vmx.arrx.push(b)
      },  
    }
  })
  
  var tasknum 
  var username = window.sessionStorage.getItem('username')
 const xhr=new XMLHttpRequest();
        xhr.open('POST','http://localhost/processjieshou');
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.send('username='+username+'&tasknum='+oneValues());
        console.log('下面是username')

        console.log(username)
        console.log('下面是任务编号')
        console.log(oneValues())    
  // const username=window.sessionStorage.getItem('username');
  xhr.onreadystatechange=function(){
  // 判断
  if(xhr.readyState == 4 && xhr.status == 200)    
  {
    // 处理服务端返回的结果
    console.log('下面是xhr.responseText')
    console.log(xhr.responseText)
    var theNeww = JSON.parse(xhr.responseText).b
    console.log('下面是theNeww')
    console.log(theNeww)
    if(xhr.responseText.indexOf(true)+1)
    {
      console.log(vmx.arrx)
      vmx.arrx = []
      console.log('0.输出vmm.arrr')
      console.log(vmx.arrx)
      var n = theNeww.length
      for(var i = 0;i<n;i++)
      {
        vmx.details(theNeww[i])
        console.log("http://localhost"+String(theNeww[i]['picurl']).substr(String(theNeww[i]['picurl']).indexOf("/picture")))
      }
    }                                      
  }
}
function yfpage(){
    window.location.href='./yfpage.html'
  } 
function rw(){
    window.location.href='./jobfachu.html'
  }             
</script>
</body>
</html>